package io.renren.controller;

import io.renren.entity.VEmpAllinfoEntity;
import io.renren.entity.VEmpInfoEntity;
import io.renren.entity.VOfficeEntity;
import io.renren.service.EmpInfoService;
import io.renren.utils.PageUtils;
import io.renren.utils.QueryAuthority;
import io.renren.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/**
 * 安全教育管理
 * 
 * @author zwli
 * @email zh_123shmily@163.com
 * @date 2017-07-18 10:51:16
 */
@RestController
@RequestMapping("empInfo")
public class EmpInfoController extends AbstractController{
	@Autowired
	private EmpInfoService empInfoService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
		QueryAuthority query = new QueryAuthority(params);
		List<VEmpInfoEntity> VEmpInfoList = empInfoService.queryList(query);
		int total = empInfoService.queryTotal(query);
		PageUtils pageUtil = new PageUtils(VEmpInfoList, total, query.getLimit(), query.getPage());
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	public R info(@PathVariable("id") Integer id){
		VEmpInfoEntity vEmpInfoEntity = empInfoService.queryObject(id);
		
		return R.ok().put("vEmpInfoEntity", vEmpInfoEntity);
	}


	@RequestMapping("/listAll")
	public R listAll(@RequestParam Map<String, Object> params){
		//查询列表数据
		QueryAuthority query = new QueryAuthority(params);
		List<VEmpAllinfoEntity> VEmpInfoList = empInfoService.queryInfoList(query);
		int total = empInfoService.queryAllTotal(query);
		PageUtils pageUtil = new PageUtils(VEmpInfoList, total, query.getLimit(), query.getPage());
		return R.ok().put("page", pageUtil);
	}

	@RequestMapping("/listOffice")
	public R listOffice(@RequestParam Map<String, Object> params){
		//查询列表数据
		QueryAuthority query = new QueryAuthority(params);
		List<VOfficeEntity> VEmpInfoList = empInfoService.queryVoffice(query);
		int total = empInfoService.queryVofficeTotal(query);
		PageUtils pageUtil = new PageUtils(VEmpInfoList, total, query.getLimit(), query.getPage());
		return R.ok().put("page", pageUtil);
	}

}
